import http from "@/axios";
import type {BaseResponse, PageBaseResponse} from "@/api/baseResponse";
import type {PageBaseRequest} from "@/api/baseRequest";

enum ApiUrl {
    pageSessionUrl = "/session/page",
    deleteSessionUrl = "/session/delete"
}

export interface SessionResponse {
    clientId: string;
    username: string;
    isCleanSession: boolean;
    keepAliveTime: number;
    connectTime: string;
}

export interface PageSessionRequest extends PageBaseRequest {
    clientId?: string;
}

export function pageSession(data: PageSessionRequest) {
    return http.post<PageBaseResponse<SessionResponse[]>>(ApiUrl.pageSessionUrl, data)
}

export function deleteSession(clientId: string) {
    return http.delete<BaseResponse<boolean>>(ApiUrl.deleteSessionUrl, {
        params: {
            clientId: clientId
        }
    });
}
